package org.geektimes.projects.user.web;

import org.eclipse.microprofile.config.Config;

/**
 * @author karidyang
 */
public class RequestConfigHolder {
    private static final ThreadLocal<Config> CONFIG_THREAD_LOCAL = new ThreadLocal<Config>();

    private static final RequestConfigHolder INSTANCE = new RequestConfigHolder();

    private RequestConfigHolder() {

    }

    public static RequestConfigHolder getInstance() {
        return INSTANCE;
    }

    public static void setConfig(Config config) {
        CONFIG_THREAD_LOCAL.set(config);
    }

    public static void removeConfig() {
        CONFIG_THREAD_LOCAL.remove();
    }

    public Config getConfig() {
        return CONFIG_THREAD_LOCAL.get();
    }
}
